This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 212
Load Numpy arrays of incompatible dtypes
#1507
Draft
souravraha
wants to merge
17
commits into
Lightning-Universe:master
Choose a base branch
from
souravraha:numpy
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
souravraha
requested review from
ethanwharris,
Borda,
tchaton,
justusschock and
krshrimali
as code owners
January 6, 2023 12:32
for more information, see https://pre-commit.ci
Borda
changed the title
Load Numpy arrays of incompatible dtypes.
Load Numpy arrays of incompatible Jan 6, 2023
dtypes
Borda
reviewed
Jan 9, 2023
Signed-off-by: souravraha <[email protected]>
for more information, see https://pre-commit.ci
The old contribution is discarded, as it was failing a required test. Now, the pixel values are scaled linearly to lie in between 0 and 255. This ensures minimal losses while loading an ndarray of dtype int64 to a PIL image. The downside for this is that every ndarray would get scaled differently, i.e. this is a sample specific scaling (rather than, say a global scaling for samples of the entire dataset). |
Borda
suggested changes
May 5, 2023
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #1507 +/- ##
=======================================
- Coverage 85% 83% -3%
=======================================
Files 291 291
Lines 12852 12856 +4
=======================================
- Hits 10982 10609 -373
- Misses 1870 2247 +377 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Handles the loading of
.npy
images of integer data-types better. Previously, the ndarrays would be unsafely cast into'uint8'
. If the original dtype were, say'int64'
, the loaded PIL Image would be different from what was intended.Now it should throw up a warning whenever there is unsafe casting. In addition, it would attempt to load a float ndarray (instead of possibly an integer array). The latter is needed as PIL can readily import from float64 ndarrays (but not, say int64 ndarrays).
Before submitting
PR review
Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.
Did you have fun?
Make sure you had fun coding 🙃